import MyTable from "@/components/MyTable";
import SearchHeader from "@/components/SearchHeader";
import useTable from "@/hooks/useTable";
import {Form } from "antd";
import { useMemo} from "react";
import { useConfig } from "./form.config";
import { getCustomerPage } from "@/services/customer/customer";

export default () => {
  const config = useConfig();
  const [form] = Form.useForm();

  const { tableProps, reset, submit } = useTable(getCustomerPage, {
    defaultFormValues: {},
    form: form,
  });

  const columns = useMemo(() => {
    return [
      {
        title: "姓名",
        dataIndex: "realName",
      },
      {
        title: "电话",
        dataIndex: "tel",
      },
      {
        title: "身份证号码",
        dataIndex: "identifyNum",
      },
    ];
  }, []);

  return (
    <>
      <div style={{ marginBottom: "16px" }}>
        <SearchHeader
          configs={config}
          form={form}
          onSubmit={submit}
          onReset={reset}
        />
      </div>

      <MyTable rowKey={"customerId"} columns={columns} {...tableProps} />
    </>
  );
};
